package CompositedPattern.demo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author： pang-yun
 * @date： 2021-12-27 14:48
 * 功能目的 ：用于  学院
 */


public class College extends OrganizedComponent {

    // list存放的是 院系
    List<OrganizedComponent> departments = new ArrayList<>();

    public College(String name, String desc) {
        super(name, desc);
    }

    @Override
    public void add(OrganizedComponent organizedComponent) {
        departments.add(organizedComponent);
    }

    @Override
    public void remove(OrganizedComponent organizedComponent) {
        departments.remove(organizedComponent);
    }

    @Override
    public void print() {
        System.out.println("-----------------"+getName()+"--------------------");
        departments.stream().forEach(OrganizedComponent::print);
    }
}
